<template>
	<view class="parent-view">
		<view class="gml-search-view">
			<image class="gml-search-icon" src="../../static/fan_fragment_chat_search.png"></image>
			<input class="gml-search-input" placeholder="搜索家谱馆" confirm-type="search" @input="onKeyInput" @confirm="searchData" />
		</view>
		<text class="gml-search-current">当前家谱馆</text>
		<view class="gml-list-item">
			<text class="item-name">{{jiapuguanData.name}}</text>
			<text class="item-address">{{jiapuguanData.ance}}</text>
			<text class="item-time">开通时间：{{jiapuguanData.createtime}}</text>
		</view>
		<text class="gml-search-all">全部家谱馆</text>
		<view class="gml-list-item" v-for="(item , index) in xianshiList" :key="index" @click="changeGM" :data-index="item">
			<text class="item-name">{{item.name}}</text>
			<text class="item-address">{{item.ance}}</text>
			<text class="item-time">开通时间：{{item.createtime}}</text>
		</view>
	</view>
</template>

<script>
	import request from '../../pages/index/request.js';
	export default {
		data() {
			return {
				jpmuseumid: "",
				inputValue:"",
				jiapuguanData: {},
				jiapuguanList: [],
				xianshiList: [],
			}
		},
		methods: {
			onLoad: function(options) {
				this.jpmuseumid = options.jpmuseumid
				this.getJpmuseumList()
			},
			onShow: function() {
				this.share.url = '../../pages/tabBar/home/index?appInviteId=' + this.appUtil.getAppInviteId()
				this.share.shareType = 1
			},
			onKeyInput: function(event) {
				this.inputValue = event.target.value
			},
			searchData:function(){
				this.xianshiList=[]
				for (var i = 0; i < this.jiapuguanList.length; i++) {
					if(this.jiapuguanList[i].name.includes(this.inputValue)){
						this.xianshiList.push(this.jiapuguanList[i])
					}
				}
			},
			//家谱馆列表
			getJpmuseumList: function() {
				var that = this
				request.post("api/common/GetJpmuseumList", {

				}).then(data => {
					that.jiapuguanList = data
					for (var i = 0; i < data.length; i++) {
						that.xianshiList.push(data[i])
						if (that.jpmuseumid == data[i].id) {
							that.jiapuguanData = data[i]
						}
					}
				})
			},
			changeGM:function(item){
				var data=item.currentTarget.dataset.index
				uni.$emit('refrash-list',data)
				uni.navigateBack()
			}
		}
	}
</script>

<style>
	@import "index.css";
</style>
